package com.webex.ta.hydra.gui.execution;

/**
 * Created by Cisco WebEx.
 * User: vegaz
 * Date: 2010-10-21
 * Time: 10:32:11
 */
public class ExecutionCallback {
    private boolean executed = false;
    private Runnable runnable;

    public void doAfterExecuted(final Runnable runnable) {
        synchronized(this) {
            this.runnable = runnable;
        }
        callback();
    }

    public void setExecuted() {
        executed = true;
        callback();
    }

    private void callback() {
        if (executed && runnable != null) {
            runnable.run();
        }
    }
}
